package com.gitee.wsl.prism4j.languages

import androidx.compose.ui.util.fastJoinToString
import com.gitee.wsl.ext.collection.joinTo
import com.gitee.wsl.ext.or
import com.gitee.wsl.prism4j.GrammarUtils
import com.gitee.wsl.prism4j.Prism4j
import com.gitee.wsl.prism4j.Prism4j.Companion.grammar
import com.gitee.wsl.prism4j.Prism4j.Companion.pattern
import com.gitee.wsl.prism4j.Prism4j.Companion.token
import com.gitee.wsl.prism4j.Prism4j.Pattern

@Suppress("unused")
//@Extend("clike")
object Prism_rust {
    val key = listOf("as", "async", "await", "break", "const", "continue", "crate", "dyn", "else", "enum",
    "extern", "false", "fn", "for", "if", "impl", "in", "let", "loop", "match", "mod", "move",
    "mut", "pub", "ref", "return", "Self", "self", "static", "struct", "super", "trait", "true",
    "type", "union", "unsafe", "use", "where", "while", "abstract", "become", "box", "do",
    "final", "macro", "override", "priv", "try", "typeof", "unsized", "virtual", "yield")


    fun create(prism4j: Prism4j): Prism4j.Grammar {
        val rust: Prism4j.Grammar = GrammarUtils.extend(
            GrammarUtils.require(prism4j, "clike"),
            "rust",
            token(
                "keyword", pattern(
                    Pattern.compile("\\b(?:${key.joinToString("|")})\\b")
                )
            ))

        return rust
    }
}
